﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.SheepMomWeaningCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomWeaningHandler
{
    public class SheepWeaningDeleteHandler:IRequestHandler<SheepWeaningDeleteCommand,Results<int>>
    {
        private readonly ISheepWeaningService _sheepWeaningService;
        private readonly IMapper _mapper;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sheepWeaningService"></param>
        /// <param name="mapper"></param>
        public SheepWeaningDeleteHandler(ISheepWeaningService sheepWeaningService, IMapper mapper)
        {
            _sheepWeaningService = sheepWeaningService;
            _mapper = mapper;
        }
        /// <summary>
        /// 批量删除/逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(SheepWeaningDeleteCommand request, CancellationToken cancellationToken)
        {
            var result =await _sheepWeaningService.DeleteSheepWeaning(request.SheepMomWeaningId.ToArray());

            return Results<int>.DataResult(result);
        }
    }
}
